import { Component, OnInit, ViewChild, ViewContainerRef, ComponentRef, ComponentFactoryResolver, EventEmitter } from '@angular/core';
import * as _ from 'lodash';
import { DataInTransitPageComponent } from "../../content/data-in-transit-page/data-in-transit-page.component";

@Component({
  selector: 'app-data-in-transit',
  templateUrl: './data-in-transit.component.html',
  styleUrls: ['./data-in-transit.component.scss'],
})
export class DataInTransitComponent implements OnInit {

 // 模版
 @ViewChild("qdiiDataInTransit", { read: ViewContainerRef })
 qdiiDataInTransit: ViewContainerRef;
 dataInTransitPageComponent: ComponentRef<DataInTransitPageComponent>;
 constructor(
   public resolver: ComponentFactoryResolver,
 ) { }

 ngOnInit() {
   if (this.dataInTransitPageComponent && this.dataInTransitPageComponent.instance) {
     this.dataInTransitPageComponent.destroy();
   }
   const viewPageComponent = this.resolver.resolveComponentFactory(DataInTransitPageComponent);
   this.dataInTransitPageComponent = this.qdiiDataInTransit.createComponent(viewPageComponent);
 }
}
